package com.acme.task4;

import java.util.Random;

public class Task4Arrays {
	public static void main(String[] args) {
		int array[] = getTask4Array(10);
		int numberOf3 = 0;
		int numberOf7 = 0;
		int numberOf9 = 0;
		for (int i : array) {
			switch (i) {
			case 3:
				numberOf3++;
				break;
			case 7:
				numberOf7++;
				break;
			case 9:
				numberOf9++;
				break;
			}
		}
		printArray(array);
		System.out.println("Number of 3: " + numberOf3);
		System.out.println("Number of 7: " + numberOf7);
		System.out.println("Number of 9: " + numberOf9);
	}
	
	private static void printArray(int[] array) {
		StringBuilder stringBuilder = new StringBuilder();
		for (int i : array) {
			stringBuilder.append(i);
			stringBuilder.append(" ");
		}
		System.out.println(stringBuilder.toString());
	}
	
	private static int[] getTask4Array(int size) {
		int[] result = new int[size];
		Random random = new Random();
		for (int i = 0; i < size; ++i) {
			result[i] = getNextRandomNumber(random);
		}
		return result;
	}
	
	private static int getNextRandomNumber(Random random) {
		switch (random.nextInt(3)) {
		case 0: 
			return 3;
		case 1:
			return 7;
		case 2:
			return 9;
		default:
			return 0;
		} 
	}
}
 